package com.hmall.item.web;

import com.hmall.brand.pojo.Brand;
import com.hmall.common.PageBean;
import com.hmall.item.service.BrandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/brand")
public class BrandController {
    @Resource
    private BrandService brandService;


    /**
     * 分页查询
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/list")
    public PageBean<Brand> queryByPage(@RequestParam(value = "page") int page,
                                       @RequestParam(value = "size") int size) {
        List<Brand> brandList = brandService.queryByPage(page, size);
        long total = brandService.getTotal();
        PageBean<Brand> pageBean = new PageBean<>();
        pageBean.setList(brandList);
        pageBean.setTotal(total);
        return pageBean;
    }


}
